//
//  ZGLTopicTableViewCell.m
//  Faker
//
//  Created by dllo on 15/11/5.
//  Copyright © 2015年 dllo. All rights reserved.
//

#import "ZGLTopicImageTableViewCell.h"
#import "ZGLTopicDetModel.h"
#import <UIImageView+AFNetworking.h>


@interface ZGLTopicImageTableViewCell ()

@property (nonatomic, strong) UIImageView *topicImage;
@property (nonatomic, strong) UILabel *titleLabel;

@end


@implementation ZGLTopicImageTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.topicImage = [[UIImageView alloc] init];
        self.titleLabel = [[UILabel alloc] init];
        [self.contentView addSubview:self.topicImage];
        [self.contentView addSubview:self.titleLabel];
    }
    return self;
}

- (void)layoutSubviews {
    [super layoutSubviews];
    self.backgroundColor = foreColor;
    [self.topicImage setFrame:CGRectMake(ScaleX * 15, 0, self.frame.size.width - ScaleX * 30, self.frame.size.height)];
    [self.titleLabel setFrame:CGRectMake(ScaleX * 20, ScaleY * 150, ScaleX * 335, ScaleY * 20)];
    self.titleLabel.textColor = [UIColor whiteColor];
    self.titleLabel.shadowColor = [UIColor blackColor];
    self.titleLabel.shadowOffset = CGSizeMake(0.3, 0.3);
    self.titleLabel.font = [UIFont systemFontOfSize:15];
    
}
- (void)setTopicModel:(ZGLTopicDetModel *)topicModel {
    if (_topicModel != topicModel) {
        _topicModel = topicModel;
    }
    if (topicModel.gallery.count == 0) {
        
    } else {
        [self.topicImage setImageWithURL:[NSURL URLWithString:topicModel.gallery[0][@"promotion_img"]] placeholderImage:[UIImage imageNamed:@"nopic"]];
        self.titleLabel.text = topicModel.gallery[0][@"title"];
    }
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
